/**
 * Copyright (c) Martijn Grootens (m.e.grootens@student.utwente.nl), 
 * University of Twente.
 * Created july 2012.
 *
 * This file is part of dbcleaner.
 * 
 * dbcleaner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * dbcleaner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with dbcleaner.  If not, see <http://www.gnu.org/licenses/>.
 */

package dbcleaner.core.tags;

/**
 * Representation of a BibTeX tag (keyword). Possibly with a new name to which
 * it should be renamed.
 */
public class Tag {
	
    // Class variable; counter.
	private static int num_tags = 0;
	
    // ID of the tag.
	private int id;
    
    // Tag as present in the old database and printable version.
	private String name;
	private String print_name;
	
	/**
	 * Constructor for a tag that is to be renamed, i.e. where
     * name.equals(print_name) == false.
	 */
	public Tag (String name, String print_name) {
        
        // Set ID, increment counter.
        this.id       = ++num_tags;
        
		this.set_name(name);
		this.set_print_name(print_name);
	}
	
	/**
	 * Constructor for a tag that is good, i.e. where
     * name.equals(print_name) == true.
	 */
	public Tag (String name) {
		this(name,name);
	}
	
    /**
     * Set Tag name.
     */
    public void set_name (String name) {
        this.name = name;
    }
    
    /**
     * Set Tag printable name.
     */
    public void set_print_name (String print_name) {
        this.print_name = print_name;
    }
    
    /**
     * Return Tag name
     */
	public String get_name () {
		return name;
	}
	
    /**
     * Return the Tag as it is to be printed.
     */
	public String get_print_name () {
		return print_name;
	}
    
    /**
     * Check equality, based on Tag name. Not on to_print version!
     */
    public boolean equals (Tag t) {
		return (this.get_name().equals(t.get_name()));
	}
    
    /**
     * Check equality, based on tag name. Not on to_print version!
     */
    public boolean equals (String s) {
		return (this.get_name().equals(s));
	}
    
    /**
     * Display Tag info, used for debugging.
     */
    public String show_info () {
        
        if (get_name().equals(get_print_name()))
            return get_name() + ";\n";
        else
            return "{" + get_name() + "}-> "+ get_print_name() + ";\n";
        
    }
    
    /**
     * Tag as it is to be printed in the BibTeX file. 
     */
    public String toString () {
        return "\t\t" + get_print_name() + ",\n";
    }
	
}